package ModelLayer;
import java.util.ArrayList;
/**
 * Write a description of class AddressBook here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class AddressBook
{
    // instance variables - replace the example below with your own
    private ArrayList<Person> addressBook;

    /**
     * Constructor for objects of class AddressBook
     */
    public AddressBook()
    {
        // initialise instance variables
        addressBook = new ArrayList<Person>();
    }

    public void addPerson(Person _person)
    {
        // put your code here
       addressBook.add(_person);
    }
    
    public Person getPerson(long _personID)
    {
        Person p = new Person();
        p = null;
        for (int i=0; i<addressBook.size(); i++)
        {
            if (addressBook.get(i).getPersonID() == _personID)
            {
                p = addressBook.get(i);
                return p;
            }
            else
                p = null;
        }
        
        return p;
    }
    
    public void deletePerson(long _personID)
    {
        for (int i = 0; i < addressBook.size(); i++)
        {
            if (addressBook.get(i).getPersonID() == _personID)
                addressBook.remove(i);
        }
    }
    
    public ArrayList<Person> getAddressBook()
    {
        return addressBook;
    }
}
